// vue2  创建   store     new  Vuex.Store({})
// vue3   创建   ceateStore({})

import { createStore } from 'vuex'

export default createStore({
  state: {
    username: 'zs'
  },
  mutations: {
    updateName (state) {
      state.username = '李四'
    }
  },
  actions: {
    updateName (ctx) {
      setTimeout(() => {
        ctx.commit('updateName')
      }, 2000)
    }
  },
  getters: {
    newName (state) {
      return state.username + '!!!!'
    }
  },

  modules: {
  }
})
